package com.jeff.tianti.cms.dao;

import com.jeff.tianti.cms.dto.font.PageBeanUid;
import com.jeff.tianti.common.dao.CustomBaseSqlDaoImpl;
import com.jeff.tianti.common.entity.PageModel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jeff.tianti.cms.entity.ConsultCategory;
import com.jeff.tianti.cms.dto.ConsultCategoryQueryDTO;
import org.apache.commons.lang3.StringUtils;

/**
 * @author liuyi
 * @desc ConsultCategoryDaoImpl类
 * @date 2019-06-28
 */

public class ConsultCategoryDaoImpl extends CustomBaseSqlDaoImpl implements ConsultCategoryDaoCustom {

    public PageModel<ConsultCategory> queryConsultCategoryPage(ConsultCategoryQueryDTO consultCategoryQueryDTO) {
        Map<String, Object> map = new HashMap<String, Object>();
        StringBuilder hql = new StringBuilder();
        hql.append("select t from ConsultCategory t where 1=1 ");
        if (consultCategoryQueryDTO != null) {
            String cmsId = consultCategoryQueryDTO.getCmsId();
            if (StringUtils.isNotBlank(cmsId) && !"-1".equals(cmsId)) {
                hql.append(" and t.cmsId = :cmsId ");
                map.put("cmsId", cmsId);
            }
        }
        hql.append(" order by t.createDate desc ");

        return this.queryForPageWithParams(hql.toString(), map, consultCategoryQueryDTO.getCurrentPage(), consultCategoryQueryDTO.getPageSize());
    }

    public List<ConsultCategory> queryConsultCategoryList(ConsultCategoryQueryDTO consultCategoryQueryDTO) {
        Map<String, Object> map = new HashMap<String, Object>();
        StringBuilder hql = new StringBuilder();
        hql.append("select t from ConsultCategory t ");
        return this.queryByMapParams(hql.toString(), map);
    }



}